/**
 * Apr 12, 2010
 */
package org.tomale.id.gis;

import java.util.List;

import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.index.SpatialIndex;
import com.vividsolutions.jts.index.quadtree.Quadtree;

/**
 * @author ferd
 *
 */
public class Layer {

	private String _name;
	private SpatialIndex _index = new Quadtree();
	
	public Layer(final String name){
		_name = name;
	}
	
	public String getName(){
		return _name;
	}
	
	public List<MapElement> getElements(final Envelope envelope){
		return _index.query(envelope);
	}
	
	public void addElement(final MapElement element){
		element.setLayer(this);
		_index.insert(element.getBounds(), element);
	}
}
